package com.framework.boc.admin.security.controller;

import com.framework.boc.admin.security.models.AuthenticationRequestBody;
import com.framework.boc.admin.security.models.AuthenticationResponseBody;
import com.framework.boc.admin.security.service.AuthenticateService;
import com.framework.boc.controller.BaseController;
import com.framework.boc.error.CommonException;
import com.framework.boc.response.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthenticateController extends BaseController {

    @Autowired
    AuthenticateService authenticateService;

    @PostMapping("/authenticate")
    public CommonResponse authenticate(@RequestBody AuthenticationRequestBody body) throws CommonException {
        AuthenticationResponseBody responseBody = authenticateService.authenticate(body);
        return CommonResponse.success(responseBody);
    }

}
